﻿@namespace CodeManDesktopBlazor.BlazorComponents.Pages.codeTemple
@typeparam K
@typeparam T

@{
	var className = $"{Model.classGenDTO.Name.ToLower().ToTitleCase()}ToDB";
	string keyList = !Model.classAttributeDTOLst.HasItem() ? "" : Model.classAttributeDTOLst.Where(a => a.IsKey.IsNotNullOrWhiteSpace()).Select(a => a.AName).Aggregate((a, b) => a + "," + b);
	string nokeyList = !Model.classAttributeDTOLst.HasItem() ? "" : Model.classAttributeDTOLst.Where(a => a.IsKey.IsNullOrEmpty()).Select(a => a.AName).Aggregate((a, b) => a + "," + b);
}

<div class="div-code">
	<p class="p-n">
		using System;
		using System.ComponentModel;
		using Microsoft.Toolkit.Mvvm.ComponentModel;
	</p>
	<br />
	@if (!Model.classGenDTO.Namespace.IsNullOrEmpty())
	{
		<p class="p-n">namespace @Model.classGenDTO.Namespace</p>
		<p class="p-n">{</p>
	}
	@if (!Model.classGenDTO.Desc.IsNullOrEmpty())
	{
		<p class="p-c">@("\n")/// @("<summary>")</p>
		<p class="p-c">/// @Model.classGenDTO.Desc</p>
		<p class="p-c">/// @("<summary>\n")</p>
	}
	<p class="p-c"> public class @(className): ObservableObject</p>
	<p class="p-c">{@("\n")</p>
	#region 私用属性
	@foreach (var item in Model.classAttributeDTOLst)
	{
		<p class="p-a"> @(item.AType == AttrTypeEnum.cchar?AttrTypeEnum.sssbyte.GetDescription():item.AType.GetDescription()) @($"_{item.AName?.ToLower()}");@("\n")</p>
	}
	#endregion
	<p class="p-c">@("\n")</p>
	#region 属性
	@foreach (var item in Model.classAttributeDTOLst)
	{
		@if (!item.ADesc.IsNullOrEmpty())
		{
			<p class="p-a">@("\n")/// @("<summary>")</p>
			<p class="p-a">/// @item.ADesc</p>
			<p class="p-a">/// @("<summary>\n")</p>
		}
		else
		{
			@("\n")
		}
		<p class="p-a">public @(item.AType == AttrTypeEnum.cchar?AttrTypeEnum.sssbyte.GetDescription():item.AType.GetDescription()) @(item.AName?.ToSplitCaseAB()) { get => @($"_{item.AName?.ToLower()}"); set => SetProperty(ref @($"_{item.AName?.ToLower()}"), value); }</p>
	}
	#endregion
	<p class="p-c">}@("\n")</p>
	@if (!Model.classGenDTO.Namespace.IsNullOrEmpty())
	{
		<p class="p-n">}</p>
	}


</div>

